package Thread.Demo9Join;

import org.junit.Test;

/**
 * @Author wangzhipeng
 * @Date 2020-08-11 4:32 下午
 * @Description
 */
public class TestJoin implements Runnable{
    //vip线程
    @Override
    public void run() {
        for(int i = 0;i < 1000;i++){
            System.out.println("线程VIP来了"+i);
        }
    }

    public static void main(String[] args) {
        //启动我们的线程
//        TestJoin testJoin = new TestJoin();
        Thread thread = new Thread(new TestJoin());
        thread.start();
        //主线程
        for(int i = 0;i < 1000;i++){
            if(i == 300){
                try {
                    thread.join();//vip线程插队开始执行
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("mian方法"+i);
        }
    }
}
